home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / ab20_archive / text / cmanual.lzh / ACM2.lzh / Requesters / Example2.c < prev    next >
C/C++ Source or Header  |  1990-01-30  |  5KB  |  118 lines

  1. /* Example2                                                             */
  2. /* This example opens a Simple requester by calling the function        */
  3. /* AutoRequest. It displays a message "Do you really want to quit?",    */
  4. /* and allows the user to choose between "Yes" and "No". The program    */
  5. /* will continue to open the requester until the user has chosen "Yes". */
  6.  
  7.  
  8.  
  9. #include <intuition/intuition.h>
  10.  
  11.  
  12.  
  13. struct IntuitionBase *IntuitionBase;
  14.  
  15.  
  16.  
  17. /* The body text for the requester: */
  18. struct IntuiText my_body_text=
  19. {
  20.   0,       /* FrontPen, colour 0 (blue). */
  21.   0,       /* BackPen, not used since JAM1. */
  22.   JAM1,    /* DrawMode, do not change the background. */
  23.   15,      /* LedtEdge, 15 pixels out. */
  24.   5,       /* TopEdge, 5 lines down. */
  25.   NULL,    /* ITextFont, default font. */
  26.   "Do you really want to quit?", /* IText, the text that will be printed. */
  27.   NULL,    /* NextText, no more IntuiText structures link. */
  28. };
  29.  
  30. /* The positive text: */
  31. /* (Printed inside the left gadget) */
  32. struct IntuiText my_positive_text=
  33. {
  34.   0,       /* FrontPen, colour 0 (blue). */
  35.   0,       /* BackPen, not used since JAM1. */
  36.   JAM1,    /* DrawMode, do not change the background. */
  37.   6,       /* LedtEdge, 6 pixels out. */
  38.   3,       /* TopEdge, 3 lines down. */
  39.   NULL,    /* ITextFont, default font. */
  40.   "Yes",   /* IText, the text that will be printed. */
  41.   NULL,    /* NextText, no more IntuiText structures link. */
  42. };
  43.  
  44. /* The negative text: */
  45. /* (Printed inside the right gadget) */
  46. struct IntuiText my_negative_text=
  47. {
  48.   0,       /* FrontPen, colour 0 (blue). */
  49.   0,       /* BackPen, not used since JAM1. */
  50.   JAM1,    /* DrawMode, do not change the background. */
  51.   6,       /* LedtEdge, 6 pixels out. */
  52.   3,       /* TopEdge, 3 lines down. */
  53.   NULL,    /* ITextFont, default font. */
  54.   "No",    /* IText, the text that will be printed. */
  55.   NULL,    /* NextText, no more IntuiText structures link. */
  56. };
  57.  
  58.  
  59.  
  60. main()
  61. {
  62.   /* Before we can use Intuition we need to open the Intuition Library: */
  63.   IntuitionBase = (struct IntuitionBase *)
  64.     OpenLibrary( "intuition.library", 0 );
  65.   
  66.   if( IntuitionBase == NULL )
  67.     exit(); /* Could NOT open the Intuition Library! */
  68.  
  69.  
  70.  
  71.   while( !AutoRequest( NULL, &my_body_text, &my_positive_text,
  72.                        &my_negative_text, NULL, NULL, 320, 72) );
  73.  
  74.   /***********************************************************************/
  75.   /* NULL,              no pointer to a window structure.                */
  76.   /* &my_body_text,     pointer to a IntuiText str. cont. the body text  */
  77.   /* &my_positive_text, pointer to a IntuiText str. cont. the pos. text  */
  78.   /* &my_negative_text, pointer to a IntuiText str. cont. the neg. text  */
  79.   /* NULL,              IDCMP flags which will satisfy the positive gad. */
  80.   /* NULL,              IDCMP flags which will satisfy the negative gad. */
  81.   /* 320,               Width, 320 pixels wide.                          */
  82.   /* 72,                Height, 72 lines high.                           */
  83.   /*                                                                     */
  84.   /* Intuition will automatically set the IDCMP flag RELVERIFY for both  */
  85.   /* of the gadgets, so we do not need to set any IDCMP flags if we do   */
  86.   /* not want to.                                                        */
  87.   /*                                                                     */
  88.   /* while( !AutoRequest(...) );                                         */
  89.   /* Since AutoRequest returns TRUE ("Yes") or FALSE ("No") we neggate   */
  90.   /* it (!), and can then use the statement in a while loop. As long as  */
  91.   /* the user selects the "No" gadget AutoRequest returns FALSE which    */
  92.   /* is changed into TRUE, and we stay in the while loop. When the user, */
  93.   /* on the other hand, selects the "Yes" gadget AutoRequest() returns   */
  94.   /* TRUE, changed into FALSE, and we leave the while loop.              */
  95.   /*                                                                     */
  96.   /* The requester will look like this:                                  */
  97.   /*                                                                     */
  98.   /* ---------------------------------------                             */
  99.   /* | System Request ================[*][*]                             */
  100.   /* ---------------------------------------                             */
  101.   /* | Do you really want to quit?      |  |                             */
  102.   /* |                                  |  |                             */
  103.   /* |                                  |  |                             */
  104.   /* | -------                   ------ |  |                             */
  105.   /* | | Yes |                   | No | |  |                             */
  106.   /* | -------                   ------ |  |                             */
  107.   /* ------------------------------------[*]                             */
  108.   /*                                                                     */
  109.   /***********************************************************************/
  110.  
  111.  
  112.  
  113.   /* Close the Intuition Library since we have opened it: */
  114.   CloseLibrary( IntuitionBase );
  115.   
  116.   /* THE END */
  117. }
  118.